#include "stdafx.h"
#include "worker_thread.h"
#include <QThread>

WorkerThread::WorkerThread(QObject* parent) : QThread(parent) {}

void WorkerThread::run()
{
    try {
        for (int i = 0; i <= 100; ++i) {
            if (isInterruptionRequested()) {
                emit taskCompleted("任务被中断");
                return;
            }

            msleep(30);
            emit progressUpdated(i);
        }

        emit taskCompleted("任务执行成功!");
    }
    catch (...) {
        emit taskError("任务执行中出现错误");
    }
}